#!/bin/bash

REPO_ROOT="/remote/iosg/data/etc/general_operations/deploy/bot-hft/hft.feed_stats/coin"
cd "${REPO_ROOT}"

HOW_MANY_DAYS_TO_RUN="$1"
GIT_COMMIT_SHA="$2"

START_DATE="$(date +%Y%m%d --date="${HOW_MANY_DAYS_TO_RUN} day ago")"
END_DATE="$(date +%Y%m%d --date="1 day ago")"
if [ -z "${GIT_COMMIT_SHA}" ]; then
  GIT_COMMIT_SHA="HEAD"
fi

echo "HOW_MANY_DAYS_TO_RUN=${HOW_MANY_DAYS_TO_RUN}"
echo "START_DATE=${START_DATE}"
echo "END_DATE=${END_DATE}"
echo "GIT_COMMIT_SHA=${GIT_COMMIT_SHA}"

# venv activate
source /remote/iosg/home/bot-hft/miniconda3/etc/profile.d/conda.sh
conda activate /remote/iosg/home/bot-hft/miniconda3/envs/coin_env
cd python

./pyrunner coin/support/feed_tool/feed_stats/app/feed_stats_checker.py \
  --db_config=/remote/iosg/data/etc/general_operations/deploy/bot-hft/hft.feed_stats/coin_deploy/research_feed_stats/db_config/db_config_prod.json \
  --start_date=${START_DATE} \
  --end_date=${END_DATE} \
  --git_commit=${GIT_COMMIT_SHA}

conda deactivate
